home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 September / Australian PC User - September 2003 (CD1).iso / resource / tools / files / tpf5.exe / Tiny Personal Firewall 5.0.msi / conditions.js < prev    next >
Encoding:
JavaScript  |  2003-07-11  |  1.5 KB  |  60 lines

  1. /*//////////////////////////////////////////////////////////////////////
  2. filename:         conditions.js
  3. copyright(c):     Tiny Software cortp 2002, 2003 (http://www.tinysoftware.com)
  4. author:         Jozef Palocko (jpalocko@tinysoftware.com)
  5. product:         Tiny Personal Firewall 5.x
  6. description:     implemetation of Global conditions HTML code
  7. ///////////////////////////////////////////////////////////////////////*/
  8.  
  9. //main function
  10.  
  11.  
  12. //return conditions string as HTMLcode
  13. function GetConditionsHtml(strFile)
  14. {
  15.    var strConditions = "";
  16.  
  17.     var xmlDoc = LoadDOM (strFile); 
  18.     
  19.      // Query a node-set.
  20.     var oNodes = xmlDoc.selectNodes('//Condition[@Type = "Global"]');
  21.     for (i=0; i<oNodes.length; i++)
  22.     {
  23.        oNode = oNodes.nextNode;
  24.        if (oNode != null) 
  25.        {
  26.            strConditions += GetCheckBoxHtml(oNode.nodeName, oNode.text, 0) + "<br>";
  27.        }
  28.     }
  29.  
  30.     return strConditions;
  31. }
  32.  
  33. //return string with Checkbox tag HTML code
  34. function GetCheckBoxHtml(strName, strText, bSelected)
  35. {
  36.     Val ="";
  37.     if (bSelected)
  38.         Val = "CHECKED";
  39.     return '<input type="checkbox" '+ Val + ' name="' + strName + '">' + strText ;
  40. }
  41.   
  42. //load XML document
  43. function LoadDOM(strFile)
  44. {
  45.     var dom;
  46.     try 
  47.     {
  48.         dom = new ActiveXObject("MSXML2.DOMDocument.4.0");
  49.         dom.async = false;
  50.         dom.validateOnParse = false;
  51.         dom.resolveExternals = false;
  52.         dom.load(strFile);
  53.     }
  54.     catch (e) 
  55.     {
  56.         alert(e.description);
  57.     }
  58.     return dom;
  59. }
  60.